/*	
   ______   ______    
  /\__  __\/\ \___\ 
  \/_/\ \_/\ \ \__/    __   __     __       
     \ \ \  \ \ \__\  /\ \ /\ \  /'__`\  
     _\_\ \  \ \ \_/_ \ \ \\_\ \/\  __/       
    /\____/   \ \_____\\ \_____/\ \____\   
    \_/__/     \/_____/ \/____/  \/____/                   
 
 	This file is part of the JEVE core API.

    JEve is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    JEve is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    Copyright 2008 JEve Project (JEveProject@gmail.com)
 */
package be.fomp.jeve.core.api.connectors;

import be.fomp.jeve.core.api.StandardAPI;
import be.fomp.jeve.core.api.url.StandardUrl;
import be.fomp.jeve.core.config.CoreConfiguration;
import be.fomp.jeve.core.exceptions.JEveConnectionException;
import be.fomp.jeve.core.exceptions.JEveParseException;
import be.fomp.jeve.core.util.ParameterString;
import org.jdom.Document;

import java.awt.*;

/**
 * <pre>
 *  ______   ______
 * /\__  __\/\ \___\
 * \/_/\ \_/\ \ \__/    __   __     __
 *    \ \ \  \ \ \__\  /\ \ /\ \  /'__`\
 *    _\_\ \  \ \ \_/_ \ \ \\_\ \/\  __/
 *   /\____/   \ \_____\\ \_____/\ \____\
 *   \_/__/     \/_____/ \/____/  \/____/
 * </pre>
 * This file is part of the JEVE core API.<br />
 * <br />
 * <p/>
 * This class contains the accessor methods for the EVE-Online API
 * which do not require an API key.
 * <p/>
 * * Default visibility: This class should only be created using the factory
 *
 * @author Sven Meys
 * @version 1.0
 */
class StandardConnector extends Connector implements StandardAPI {

	/**
	 * Constructor which takes a config setting. This configures the correct
	 * proxy settings to ensure the client can access the internet.
	 *
	 * @param config The configuration settings
	 */
	protected StandardConnector(CoreConfiguration config) {
		
		super(config);
	}

	
	public final Document getAllianceList() throws JEveConnectionException, JEveParseException {

		return getDocumentData(StandardUrl.ALLIANCE_LIST);
	}


	public final Document getCharacterID(String names) throws JEveConnectionException, JEveParseException {

		ParameterString parameters = new ParameterString("names", names);

		return getDocumentData(StandardUrl.CHARACTER_ID, parameters);
	}


	public final Document getConquerableStationList() throws JEveConnectionException, JEveParseException {

		return getDocumentData(StandardUrl.CONQUERABLE_STATION_LIST);
	}


	public final Document getCorporationSheet(int userID, int corporationID) throws JEveConnectionException, JEveParseException {

		ParameterString parameters = new ParameterString();
		parameters.addParameter("userID", userID)
				.addParameter("corporationID", corporationID);

		return getDocumentData(StandardUrl.CORPORATION_SHEET, parameters);
	}

	
	public final Document getErrorList() throws JEveConnectionException, JEveParseException {

		return getDocumentData(StandardUrl.ERROR_LIST);
	}

	
	public final Document getJumps() throws JEveConnectionException, JEveParseException {

		return getDocumentData(StandardUrl.JUMPS);
	}

	
	public final Document getKills() throws JEveConnectionException, JEveParseException {

		return getDocumentData(StandardUrl.KILLS);
	}

	
	public final Image getPortrait(int size, int characterID) throws JEveConnectionException, JEveParseException {

		if (size < ((64 + 256) / 2)) {
			size = 64;
		} else {
			size = 256;
		}

		ParameterString parameters = new ParameterString().addParameter("s", size)
				.addParameter("c", characterID);

		return getImageData(StandardUrl.PORTRAIT, parameters);
	}

	
	public final Document getRefTypes() throws JEveConnectionException, JEveParseException {

		return getDocumentData(StandardUrl.REF_TYPES);
	}

	
	public final Document getSkillTree() throws JEveConnectionException, JEveParseException {

		return getDocumentData(StandardUrl.SKILL_TREE);
	}

	
	public final Document getSovereignty() throws JEveConnectionException, JEveParseException {

		return getDocumentData(StandardUrl.SOVEREIGNITY);
	}
}